package ar.uba.fi.RSACryptoFiuba.view.commons;

import java.awt.Dimension;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;

@SuppressWarnings("serial")
public class ButtonsPanel extends JPanel {
	
	private JButton modeButton;
	private JButton firstButton;
    private JButton previousButton;
    private JButton nextButton;
    private JButton lastButton;
	
	public ButtonsPanel(ActionListener modeButtonActionListener, ActionListener firstButtonActionListener, 
			ActionListener previousButtonActionListener, ActionListener nextButtonActionListener, ActionListener lastButtonActionListener){
		
		this.initComponents(modeButtonActionListener, firstButtonActionListener, previousButtonActionListener, 
				nextButtonActionListener, lastButtonActionListener);		
	}

	private void initComponents(ActionListener modeButtonActionListener, ActionListener firstButtonActionListener, 
			ActionListener previousButtonActionListener, ActionListener nextButtonActionListener, ActionListener lastButtonActionListener) {
		
		modeButton = new JButton();
		modeButton.setText("Modo");
		modeButton.setPreferredSize(new Dimension(100, 30));
		modeButton.addActionListener(modeButtonActionListener);
	    
		firstButton = new JButton();
		firstButton.setText("Inicio");
		firstButton.setMaximumSize(new Dimension(100, 30));
		firstButton.setMinimumSize(new Dimension(100, 30));
		firstButton.setPreferredSize(new Dimension(100, 30));
		firstButton.setEnabled(false);
		firstButton.addActionListener(firstButtonActionListener);  

	    previousButton = new JButton();
	    previousButton.setText("Anterior");
	    previousButton.setMaximumSize(new Dimension(100, 30));
	    previousButton.setMinimumSize(new Dimension(100, 30));
	    previousButton.setPreferredSize(new Dimension(100, 30));
	    previousButton.setEnabled(false);
	    previousButton.addActionListener(previousButtonActionListener);

	    nextButton = new JButton();    
        nextButton.setText("Siguiente");
        nextButton.setMaximumSize(new Dimension(100, 30));
        nextButton.setMinimumSize(new Dimension(100, 30));
        nextButton.setPreferredSize(new Dimension(100, 30));
        nextButton.addActionListener(nextButtonActionListener);

        lastButton = new JButton();
        lastButton.setText("Fin");
        lastButton.setMaximumSize(new Dimension(100, 30));
        lastButton.setMinimumSize(new Dimension(100, 30));
        lastButton.setPreferredSize(new Dimension(100, 30));
        lastButton.addActionListener(lastButtonActionListener);
        
        GroupLayout buttonsPanelLayout = new GroupLayout(this);
        this.setLayout(buttonsPanelLayout);
        buttonsPanelLayout.setHorizontalGroup(
            buttonsPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
            .addGroup(buttonsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(buttonsPanelLayout.createSequentialGroup()
                    .addGap(34, 34, 34)
                    .addComponent(modeButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(firstButton, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(previousButton, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(nextButton, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(lastButton, GroupLayout.PREFERRED_SIZE, 110, GroupLayout.PREFERRED_SIZE)
                    .addGap(34, 34, 34)))
        );
        buttonsPanelLayout.setVerticalGroup(
            buttonsPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 48, Short.MAX_VALUE)
            .addGroup(buttonsPanelLayout.createParallelGroup(Alignment.LEADING)
                .addGroup(buttonsPanelLayout.createSequentialGroup()
                    .addGap(6, 6, 6)
                    .addGroup(buttonsPanelLayout.createParallelGroup(Alignment.BASELINE)
                        .addComponent(modeButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(firstButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(previousButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(nextButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(lastButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
		
	}
		
	public JButton getModeButton() {
		return modeButton;
	}

	public void setModeButton(JButton modeButton) {
		this.modeButton = modeButton;
	}

	public JButton getFirstButton() {
		return firstButton;
	}

	public void setFirstButton(JButton firstButton) {
		this.firstButton = firstButton;
	}

	public JButton getPreviousButton() {
		return previousButton;
	}

	public void setPreviousButton(JButton previousButton) {
		this.previousButton = previousButton;
	}

	public JButton getNextButton() {
		return nextButton;
	}

	public void setNextButton(JButton nextButton) {
		this.nextButton = nextButton;
	}

	public JButton getLastButton() {
		return lastButton;
	}

	public void setLastButton(JButton lastButton) {
		this.lastButton = lastButton;
	}
}
